#include <QRegularExpression>
#include <QDateTime>
#include <QThread>
#include "mp4.h"
#include <iostream>

/*!
 * \brief filterLiveMp4s
 * \param mp4s
 * \return filtered size
 */
int filterLiveMp4s(QVector<Mp4> &mp4s) {
    for (QVector<Mp4>::iterator it = mp4s.begin(); it != mp4s.end(); ) {
        it->fileInfo.refresh();
//        std::cout << it->fileInfo.absoluteFilePath().toStdString() <<
//                     " oldsize:" << it->size <<
//                     " newsize:" << it->fileInfo.size() <<
//                     std::endl;
        if (it->fileInfo.size() == it->size) {
            it = mp4s.erase(it);
        } else {
            ++it;
        }
    }
    return mp4s.size();
}

void updateLiveMp4sSize(QVector<Mp4> &mp4s) {
    for (QVector<Mp4>::iterator it = mp4s.begin(); it != mp4s.end(); it++) {
        it->fileInfo.refresh();
        it->size = it->fileInfo.size();
    }
}
